#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pydantic import BaseModel, Field, ConfigDict
from typing import List, Dict, Any, Optional

class DocumentResponse(BaseModel):
    """文档处理响应模型"""
    model_config = ConfigDict(arbitrary_types_allowed=True)
    
    file_name: str = Field(..., description="原始文件名")
    markdown: str = Field(..., description="转换后的Markdown内容")
    task_id: str = Field(..., description="任务ID")
    process_time: float = Field(..., description="处理时间（秒）")
    total_time: float = Field(..., description="总耗时（秒）")
    engine_name: str = Field(..., description="使用的引擎名称")
    markdown_file: str = Field(..., description="Markdown文件路径")

class GenerateQARequest(BaseModel):
    """生成知识问答对请求模型"""
    model_config = ConfigDict(arbitrary_types_allowed=True)
    
    source_name: str = Field(..., description="来源名称")
    system_name: str = Field(..., description="系统名称")
    generate_method: str = Field(..., description="生成方式，可选值：text_split 或 ai_qa")
    chunk_size: Optional[int] = Field(500, description="文本块大小（字符数）")
    overlap: Optional[int] = Field(50, description="重叠大小（字符数）")
    markdown_content: str = Field(..., description="Markdown内容")

class QAPair(BaseModel):
    """问答对模型"""
    Q: str = Field(..., description="问题")
    A: str = Field(..., description="答案")
    source: str = Field(..., description="来源段落")

class GenerateQAResponse(BaseModel):
    """生成知识问答对响应模型"""
    task_id: str = Field(..., description="任务ID")
    file_name: str = Field(..., description="文件名")
    system_name: str = Field(..., description="系统名称")
    source_name: str = Field(..., description="来源名称")
    qa_pairs: List[QAPair] = Field(..., description="问答对列表")
    
class ErrorResponse(BaseModel):
    """错误响应模型"""
    detail: str = Field(..., description="错误详情") 